package com.scs.application.modules.upms.model;

import com.scs.application.core.model.TreeModel;
import com.scs.application.core.model.TreeNode;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.modules.upms.entity.Menu;

import java.util.List;

/**
 */
public class MenuTreeModel extends TreeModel<Menu> {
    public MenuTreeModel(List<Menu> data, String labelFieldName) {
        super(data, labelFieldName);
    }

    public MenuTreeModel(List<Menu> data, String labelFieldName, TreeNode root) {
        super(data, labelFieldName, root);
    }

    public MenuTreeModel(List<Menu> data, String idFieldName, String labelFieldName, String parentFieldName, TreeNode root) {
        super(data, idFieldName, labelFieldName, parentFieldName, root);
    }

    public MenuTreeModel(List<Menu> data, String idFieldName, String labelFieldName, String parentFieldName, String sortFieldName, TreeNode root) {
        super(data, idFieldName, labelFieldName, parentFieldName, sortFieldName, root);
    }

    @Override
    protected void addExtraProperties(TreeNode node, Menu entity) {
        node.addProperty(StringUtils.isNotBlank(entity.getUrl()), "url", entity.getUrl());
        node.addProperty(StringUtils.isNotBlank(entity.getIcon()), "icon", entity.getIcon());
        node.addProperty("target", entity.getTarget());
        node.addProperty("flagApp", entity.getFlagApp());
        node.addProperty("isShow", entity.getIsShow());
        node.addProperty(StringUtils.isNotBlank(entity.getBadgeUrl()), "badgeUrl", entity.getBadgeUrl());
        node.addProperty(StringUtils.isNotBlank(entity.getBadgeField()), "badgeField", entity.getBadgeField());
    }
}
